package cn.edu.java.io.inputstream;

import lombok.SneakyThrows;

import java.io.ByteArrayInputStream;

public class ByteArrayInputStreamDemo {
    @SneakyThrows
    public static void main(String[] args) {
        // 创建字节数组
        byte[] byteArray = {65, 66, 67, 68, 69};


        // 创建ByteArrayInputStream对象
        ByteArrayInputStream inputStream = new ByteArrayInputStream(byteArray);

        // 读取字节流并输出
        int data;
        while ((data = inputStream.read()) != -1) {
            System.out.print((char) data + " ");
        }

        // 关闭输入流
        inputStream.close();
    }
}

